package com.action;

import java.io.Serializable;
import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;

import com.entity.Pagination;
import com.entity.Person;
import com.opensymphony.xwork2.ActionSupport;
import com.service.PersonService;
 
public class PerAction extends BaseAction implements Serializable {
	@Autowired
	private PersonService personService;
	private List<Person> persons;
	private Pagination page;
	private Person person;
	private int pageNum = 1;// dwz分页使用
	private int numPerPage = 20;
	public Pagination getPage() {
		return page;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(int numPerPage) {
		this.numPerPage = numPerPage;
	}

	public void setPage(Pagination page) {
		this.page = page;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public List<Person> getPersons() {
		return persons;
	}

	public void setPersons(List<Person> persons) {
		this.persons = persons;
	}
	@Action(results={@Result(name="success", location="lookupper.jsp") })
	@Override
	public String execute() throws Exception {
		page = new Pagination(pageNum,numPerPage);	
		persons = personService.getAllPersons(page,person);
		return "success";
	}

}
